perm filename IPUPL.H[11,HE] blob
sn#688214 filedate 1982-12-06 generic text, type T, neo UTF8
/*
* puplib.h THIRD VERSION
*
* This is an "include" file which defines the various data
* types used in the Pup implementation.
*
* Jeffrey Mogul 22-June-1980 13-Jan-81
* (after jks's initial version that included other things, too.)
*/
#ifndef PUPLIBDEFINED /* watch for nested includes */
#define PUPLIBDEFINED
/* HACK !!!! */
#define PUP_DEFAULTNET 050 /* stanford-net */
#include <pupmachdep.h>
#ifdef VAX
#ifndef major
#include <sys/types.h>
#endif major
#include <sys/enet.h>
#endif
#ifdef MC68000
struct enfilter {
int mask; /* mask word */
unsigned short enptype; /* ethernet packet type */
unsigned long dstsock; /* pup dest socket */
unsigned char dsthost; /* pup dest host */
};
#define ENPTYPE 1 /* check packet for ethernet packet type */
#define DSTSOCK 2 /* check packet for pup destination socket */
#define DSTHOST 4 /* check packet for pup destination socket */
#endif
/*
* Pup transport Media
*/
#define ETHERNET 1
#define NOCKSUM (-1)
#define forever for(;;)
#ifndef NULL /* avoid unpleasant warning messages */
#define NULL 0
#endif
#define roundup(x) ( (x+1) & ~1 ) /* round x up to nearest even */
#define rounddown(x) ( (x) & ~1 ) /* round x down to nearest even */
#define INFINITY 0 /* timeout values (in 1/60th sec) */
#define ONESEC 60
#define TENMIN 36000
#define MAXPUPDATALEN (532) /* maximum Pup data (bytes) */
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned char Net;
typedef unsigned char Host;
typedef unsigned long Socket;
struct Port { /* describes Host#Net#Socket tuple */
Host host;
Net net;
/* warning! There is a spare shortword between net and socket! */
Socket socket;
};
/* in-packet version of Port, workaround a C compiler "restriction".
* Since the C compiler tries to align longwords in structures
* on longword boundaries (grrr), the Socket fields are broken
* into two shorts, e.g., PupDstFSocket and PupDstBSocket. The
* F and B stand for "front" and "back", to avoid any byte-order
* related naming melees.
*/
struct packedPort {
#ifdef PUP__NNSO /* non-standard byte order */
Host pk_Host;
Net pk_Net;
#else /* standard byte order */
Net pk_Net;
Host pk_Host;
#endif
ushort pk_FSocket, pk_BSocket; /* "front" and "back" socket words */
};
union PakFilter { /* one variant for each transport medium */
struct enfilter en; /* enet filter */
};
struct PupChan { /* descriptor for Pup transport channel */
int ifid; /* file id for input */
int ofid; /* file id for output */
uchar transport; /* transport medium -- NOT like PupTransport */
short mode; /* channel mode bits */
long timeout; /* read timeout on this channel */
Host ImmHost; /* First hop host */
Net ImmNet; /* net for first hop */
struct Port SrcPort; /* source port */
struct Port DstPort; /* destination port */
union PakFilter filter; /* packet filter for this channel */
/* note that this field is really
* the address of some sort of
* filter structure */
#ifdef VAX
int TimeoutSet; /* true if timeout is set at lowest level */
#endif VAX
long mystic; /* "magic" number for consistency checks */
};
/*
* bit definitions for mode word in PupChan structure.
*/
#define PCM_RCHECKSUM 01 /* check checksum on read */
#define PCM_WCHECKSUM 02 /* compute and send checksum on write */
#define PCM_BROADCAST 04 /* accept broadcasts on read */
#define PCM_RFIXLAST 010 /* byte swap last word in read buffers */
#define PCM_WFIXLAST 020 /* byte swap last word in write buffers */
/* These two are for NNSO byte order
* machines communicating with each other;
* they tell pupread/pupwrite to make
* the garbage byte appear in the right
* place, without actually swapping the
* whole buffer. */
#define PCM_IGNBADCKS 040 /* ignore packets with bad checksums */
#define PCM_NORCHECKSUM 0
#define PCM_NOWCHECKSUM 0
#define PCM_NOBROADCAST 0
#define PCM_NORFIXLAST 0
#define PCM_NOWFIXLAST 0
#define PCM_NOIGNBADCKS 0
/*
* "mystic" number -- the mystic field of a pupchan should only contain
* this value if it is properly initialized and open.
*/
#define PC_MYSTIC 0xfacade
extern char PupErrMsg[128]; /* space for this defined elsewhere */
#endif